#include "ecb/benchmarks/mpb/PeakFunctionOne.h"

#include "ecb/base/Math.h"
#include "ecb/base/Matrix2D.h"

#include <math.h>
namespace ecb {

    namespace mpb {

        PeakFunctionOne::PeakFunctionOne() { }

        PeakFunctionOne::~PeakFunctionOne() { }

        scalar PeakFunctionOne::f(const std::vector<scalar>& x, const Matrix2D& peaks, int peakIndex) {
            double dummy = Math::Pow2(x[0] - peaks[peakIndex][0]);
            for (int j = 1; j < x.size(); j++) {
                dummy += Math::Pow2(x[j] - peaks[peakIndex][j]);
            }

            return peaks[peakIndex][x.size() + 1] /
                    (1 + (peaks[peakIndex][x.size()]) * dummy);
        }

        std::string PeakFunctionOne::toString() const{
            return "PeakFunctionOne";
        }
    }
}
